//
//  LNViewController.m
//  YKFuncation
//
//  Created by yinyakun on 10/30/2018.
//  Copyright (c) 2018 yinyakun. All rights reserved.
//

#import "LNViewController.h"
//#import "LNLoginViewController.h"

#import "LNRecordManager.h"


@interface LNViewController (){
//    NSString *fileName;
}
@property (weak, nonatomic) IBOutlet UILabel *lb_db;
@property (weak, nonatomic) IBOutlet UILabel *label_info;
//    @property (nonatomic,strong)LNTranslateRequest *request;
@end

@implementation LNViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

//    _request = [[LNTranslateRequest alloc] init];

//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        LNLoginViewController *loginVC = [[LNLoginViewController alloc] initWithNibName:@"LNLoginViewController" bundle:[self wg_subBundleWithBundleName:@"YKFuncation" targetClass:[LNLoginViewController class]]];
////        LNLoginViewController *loginVC = [[LNLoginViewController alloc] init];
//
//        [self presentViewController:loginVC animated:YES completion:nil];
//    });

}

//- (NSBundle *)wg_subBundleWithBundleName:(NSString *)bundleName targetClass:(Class)targetClass{
//        //并没有拿到子bundle
//    NSBundle *bundle = [NSBundle bundleForClass:targetClass];
//        //在这个路径下找到子bundle的路径
//    NSString *path = [bundle pathForResource:bundleName ofType:@"bundle"];
//        //根据路径拿到子bundle
//    return path?[NSBundle bundleWithPath:path]:[NSBundle mainBundle];
//
//    /*
//     这种方式也可以
//     NSBundle *bundle = [NSBundle bundleForClass:targetClass];
//     NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
//     return path?[NSBundle bundleWithURL:url]:[NSBundle mainBundle];
//     */
//}
- (IBAction)record:(id)sender {
    self.label_info.text = @"开始:";
    [[LNRecordManager shareInstance] translateBeginWithClientID:@"1732DCA7A9F84B649B1D18B061AEA386" clientSecret:@"C03D97E0AA3D4D4496F7EF90B886A718" appKey:@"09E2C806795846B0A29B98C469C333DF" translateCB:^(NSDictionary *callback) {
        NSString *content = callback[@"content"];
        self.label_info.text = content;
    } andDBCB:^(NSDictionary *callback) {
        NSString *db = callback[@"db"];
        self.lb_db.frame = CGRectMake(
                                      self.lb_db.frame.origin.x,
                                      self.lb_db.frame.origin.y,
                                      [db floatValue],
                                      self.lb_db.frame.size.height
                                      );
    }];
}

- (IBAction)pause:(id)sender {

}
- (IBAction)end:(id)sender {
    [[LNRecordManager shareInstance] translateEnd:^(NSDictionary *callback) {
        NSString *content = callback[@"content"];
        self.label_info.text = content;
    }];
}
- (IBAction)play:(id)sender {

}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
